package com.ruoyi.bantong.controller;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bantong.domain.BtPlacecardPoolDetails;
import com.ruoyi.bantong.service.IBtPlacecardPoolDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 席位玩法详情Controller
 * 
 * @author laohei
 * @date 2021-01-24
 */
@RestController
@RequestMapping("/bantong/details")
public class BtPlacecardPoolDetailsController extends BaseController
{
    @Autowired
    private IBtPlacecardPoolDetailsService btPlacecardPoolDetailsService;

    /**
     * 查询席位玩法详情列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(BtPlacecardPoolDetails btPlacecardPoolDetails)
    {
        startPage();
        List<BtPlacecardPoolDetails> list = btPlacecardPoolDetailsService.selectBtPlacecardPoolDetailsList(btPlacecardPoolDetails);
        return getDataTable(list);
    }

    /**
     * 查询席位玩法详情列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:details:list')")
    @GetMapping("/palylist")
    public TableDataInfo palylist(BtPlacecardPoolDetails btPlacecardPoolDetails)
    {
        Integer btUserId = SecurityUtils.getBtUserId();
        btPlacecardPoolDetails.setUserId(btUserId);
        startPage();
        List<BtPlacecardPoolDetails> list = btPlacecardPoolDetailsService.selectBtPlacecardPoolDetailsListByUserId(btPlacecardPoolDetails);
        return getDataTable(list);
    }

    /**
     * 导出席位玩法详情列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:details:export')")
    @Log(title = "席位玩法详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BtPlacecardPoolDetails btPlacecardPoolDetails)
    {
        List<BtPlacecardPoolDetails> list = btPlacecardPoolDetailsService.selectBtPlacecardPoolDetailsList(btPlacecardPoolDetails);
        ExcelUtil<BtPlacecardPoolDetails> util = new ExcelUtil<BtPlacecardPoolDetails>(BtPlacecardPoolDetails.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取席位玩法详情详细信息
     */
    //@PreAuthorize("@ss.hasPermi('bantong:details:query')")
    @GetMapping(value = "/{ppdId}")
    public AjaxResult getInfo(@PathVariable("ppdId") Integer ppdId)
    {
        return AjaxResult.success(btPlacecardPoolDetailsService.selectBtPlacecardPoolDetailsById(ppdId));
    }

    /**
     * 新增席位玩法详情palylist
     */
    //@PreAuthorize("@ss.hasPermi('bantong:details:add')")
    @Log(title = "席位玩法详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BtPlacecardPoolDetails btPlacecardPoolDetails)
    {
        return toAjax(btPlacecardPoolDetailsService.insertBtPlacecardPoolDetails(btPlacecardPoolDetails));
    }

    /**
     * 修改席位玩法详情
     */
    //@PreAuthorize("@ss.hasPermi('bantong:details:edit')")
    @Log(title = "席位玩法详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BtPlacecardPoolDetails btPlacecardPoolDetails)
    {
        return toAjax(btPlacecardPoolDetailsService.updateBtPlacecardPoolDetails(btPlacecardPoolDetails));
    }

    /**
     * 删除席位玩法详情
     */
    //@PreAuthorize("@ss.hasPermi('bantong:details:remove')")
    @Log(title = "席位玩法详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ppdIds}")
    public AjaxResult remove(@PathVariable Integer[] ppdIds)
    {
        return toAjax(btPlacecardPoolDetailsService.deleteBtPlacecardPoolDetailsByIds(ppdIds));
    }
}
